// ==UserScript==
// @name         Feeldy.com
// @namespace    https://git.oschina.net/yjbc/userscripts
// @version      0.4
// @author       映阶碧草
// @match        https://feedly.com/*
// @grant        GM_addStyle
// @grant        GM_getResourceText
// @resource     index.css index.css
// @require      style.js
// @require      https://cdn.rawgit.com/chuson1996/really-smooth-scroll/ff3210e1/build/really-smooth-scroll.js
// ==/UserScript==

var feelyTabsArea = document //.querySelector('#feedlyTabs')

/**
 *  提升：左侧目录操作体验
 *  1.替换默认的目录单击动作行为为“展开目录” 
 *  2.单击目录后将所有其他目录收缩起来
 */
feelyTabsArea.addEventListener('click', collapseAllSiblingCategories)

function collapseAllSiblingCategories(event) {
    let clickedCategory
    if (event.target.matches('[id^="user/"][id$=tab_label]')) {
        event.stopPropagation()
        clickedCategory = event.target.parentNode.querySelector('.handle')
        clickedCategory.click()
        return
    }
    if (!event.target.matches('.handle')) {
        return
    }

    clickedCategory = event.target
    const categories = feelyTabsArea.querySelectorAll('.handle')
    for (var category of categories) {
        if (category == clickedCategory || !category.classList.contains('expanded')) {
            continue
        }
        category.click()
    }
}

/**
 * 样式调整
 * 1.增加条目内容的字号大小；字体改为“微软雅黑”
 */
const style = document.createElement('style')
style.textContent = `
    .lora .entryBody {
        font-family: 微软雅黑;
    }
`
document.body.appendChild(style)

/**
 * 平滑滚动,
 * 2017/9/4 效果不是太好，现在禁用掉
 */
//ReallySmoothScroll.shim();
// If you want to adjust the scrolling sensitivity (Optional) 
// ReallySmoothScroll.config({
//   mousewheelSensitivity: 6, // Default 
//   keydownSensitivity: 6 // Default (When you press arrow down/up key) 
// });

